package cn.wolfcode.rbac.util;

import lombok.Getter;
import lombok.Setter;

import java.util.Collections;
import java.util.List;

/**
 * @Description TODO
 * @ClassName PageResult
 * @Author luhui
 * @date 2020.06.13 14:00
 * @version: 1.0
 */
@Getter
@Setter
public class PageResult {

    public static final PageResult DEFAULT_PAGE = new PageResult(1,3, Collections.emptyList(),0);
    private Integer currentPage;
    private Integer pageSize;

    private List list;
    private Integer count;
    private Integer endPage;
    private Integer prePage;
    private Integer nextPage;

    public PageResult(Integer currentPage, Integer pageSize, List list, Integer count) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.list = list;
        this.count = count;
        this.endPage = count % pageSize == 0 ? count/pageSize : count/pageSize +1;
        this.nextPage = this.currentPage +1 <=this.endPage ? this.currentPage+1 :endPage;
        this.prePage = this.currentPage -1 >=1 ? this.currentPage-1 :1;
    }
}